package com.test.web.testng;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;

public class LogCustomListener extends TestListenerAdapter {

    private static final Logger logger = LogManager.getLogger();
    final Level TestNG_Fail = Level.forName("TestNG_Fail", 250);
    final Level TestNG_Skip = Level.forName("TestNG_Skip", 300);
    final Level TestNG_Success = Level.forName("TestNG_Success", 350);

    @Override
    public void onTestFailure(ITestResult tr) {
        logger.log(TestNG_Fail,"TestNg-失败："+tr.getTestClass().getName()+"."+tr.getName());
    }

    @Override
    public void onTestSkipped(ITestResult tr) {
        logger.log(TestNG_Skip,"TestNg-跳过："+tr.getTestClass().getName()+"."+tr.getName());
    }

    @Override
    public void onTestSuccess(ITestResult tr) {
        logger.log(TestNG_Success,"TestNg-成功："+tr.getTestClass().getName()+"."+tr.getName());
    }
}
